import React, { useEffect } from 'react';
import { fetchUser } from "../core/api";
import useData from "../core/useData";

const User = ({ staticContext }) => {
  console.log('staticContext ', staticContext)

  const [user, setUser] = useData(staticContext, fetchUser, {name:'', age: '', id: ''})
  const { name, age, id } = user

  return (
    <section>
      <h1 onClick={() => console.log('hello User')}>User Page</h1>
      <div><span>{id}</span>-<span>{name}</span>-<span>{age}</span></div>
    </section>
  )
}

// 挂载静态获取数据方法
User.getData = fetchUser

export default User